package com.github.live.base;

import android.content.Context;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @ClassName GloabConfig
 * @description:
 * @author: biao532
 * @create: 2024-02-02 10:15
 * @Version 1.0
 **/
public class GloabConfig {
    // 是否启用http服务
    private boolean httpEnable;
    // 线程池核心线程数
    private int threadPoolCoreSize;
    // EventBus线程数
    private int eventBusThreadSize;
    // 日志等级
    private int logLevel;
    public GloabConfig(Context context) {
        Properties properties = new Properties();
        File config = new File(context.getExternalFilesDir(""), "config.properties");
        try(InputStream stream = new FileInputStream(config)) {
            properties.load(stream);
        } catch (IOException e) {
        }
        this.httpEnable = Boolean.valueOf(properties.getProperty("httpEnable", "false"));
        this.threadPoolCoreSize = Integer.valueOf(properties.getProperty("threadPoolCoreSize", "2"));
        this.eventBusThreadSize = Integer.valueOf(properties.getProperty("eventBusThreadSize", "1"));
        // < 0, 使用代码预设值
        this.logLevel = Integer.valueOf(properties.getProperty("logLevel", "-1"));
    }

    public int getThreadPoolCoreSize() {
        return threadPoolCoreSize;
    }

    public int getEventBusThreadSize() {
        return eventBusThreadSize;
    }

    public boolean isHttpEnable() {
        return httpEnable;
    }

    public int getLogLevel() {
        return logLevel;
    }

}
